<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title><?=getValInArr(getSess(SESS_DIC), array('webInfo', 'webtitle'))?></title>
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>
    <meta content="yes" name="apple-mobile-web-app-capable"/>
    <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
    <meta content="telephone=no" name="format-detection"/>
    <script src="<?php echo base_url() . 'public/home/js/' ?>jquery.js"></script>
    <?php include_once "public/home/html/bootstrap.php"?>
    <?php include_once "public/home/html/img_big.php"?>
    <?php include_once "public/home/html/mobile_dialog.php";?>
    <link rel="stylesheet" href="<?php echo base_url() . 'public/h_ui/lib/Hui-iconfont/1.0.8/' ?>iconfont.css">
    <link rel="stylesheet" href="<?php echo base_url() . 'public/home/css/' ?>mui.min.css">
    <?php include_once "public/home/html/alert.php"?>
    <script type="text/javascript" src="<?php echo base_url() . 'public/home/js/' ?>function.js"></script>
</head>
<body>
    <style>
        body{
            padding: 3%;
            text-align: left;
            background-color: #ffffff;
        }
        .content{
            margin-top:60px;
        }
        .div{
            margin-top: 20px;
        }
        .title{
             text-align: left;
        }
        .border{
            margin-top: 20px;
            margin-bottom: 20px;
            border-radius: 5px;
            padding: 10px;
            border:1px solid #d2d2d2;
        }
        .pop .btn{
            padding-left: 10%;
            padding-right: 10%;
        }
        .header{
            padding: 0
        }
        .list{
            z-index: 1;
            top: 50;
            position: fixed;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            width: 100%;
            height: 100%;
            background: white;
            display: none;
            overflow-x: hidden;
        }
        .search-border{
            background: #eaeaea;
            border-radius: 20px;
            height: 50px;
            margin-top: 50px;
            position: fixed;
            width: 100%;
        }
        .search-border img{
            width: 20px;
            margin-left: 20px;
        }
        .search-border input{
            height: 44px;
            margin-top: 3px;
            margin-left: 15px;
            border: none;
            background: #eaeaea;
            width: 56%;
        }
        .search-list{
            margin-top: 100px;
        }
        .search-list div{
            /*height: 40px;*/
            line-height: 40px;
            text-align: center;
            border-bottom: 1px solid #ececec;
        }
        #forward{
            display: none
        }

    </style>
    <input type="hidden" name='url' value="<?php echo base_url() ?>">
    <input type="hidden" id="type" value="<?=$type?>">
    <input type="hidden" id="id" value="<?=$detail['id']?>">
    <div class="search-head header mui-bar mui-bar-nav row" style="background-color: #f7f9fa; border:none;">
        <div class="col-xs-1" style="margin-top: 3%">
            <a class=" Hui-iconfont Hui-iconfont-slider-left" href="javascript:void(0)" onclick="history.back();" style="color: #C9C9C9"></a>
        </div>
        <div class="col-xs-11">
            <h1 class="mui-title" style="color:#333;margin-left: -5%">信息反馈处理</h1>
        </div>
    </div>

    <div class="content">
       <div>
           <div class="title">反馈类别：<?=$detail['category']?></div>
       </div>
       <div class="div">
           <div class="title">反馈意见：</div>
           <div class="border">
               <?=$detail['content']?>
           </div>
       </div>
        <div>
           <div class="title">转发目标用户：<?=$detail['username']?></div>
       </div>
       <div class="div">
           <div class="title">处理意见和结果：</div>
           <?php if($detail['status']==FeedBackStatus::ToAudit[XPHEnum::Value]): ?>
           <textarea rows="6" style="margin-top: 10px;" id="result"></textarea>
            <?php else: ?>
            <div  class="border"><?=$detail['result'];?></div>
            <?php endif ?>
       </div>
    </div>
    <div class="list">
        <div class="search-border">
               <img src="<?=base_url()?>public/home/images/search-icon.png">
               <input type="" name="" id="search" data-id="" placeholder="请输入转发人姓名/工号" oninput="change()">
               <button class="btn btn-primary" onClick="doForward(this)" id="forward">确认转发</button>
           </div>
           <div class="search-list">
               
           </div>
    </div>

<div class="pop">
    <?php if($detail['status']==FeedBackStatus::ToAudit[XPHEnum::Value] && $detail['is_studentInfoOfficer'] == CommonWhether::Not[XPHEnum::Value]): ?>
    <button class="btn btn-primary radius" type="button" id="save">保存</button>
    <button class="btn btn-warning radius" type="button" id="relay">转发</button>
    <button class="btn btn-success" type="button" id="end">结束</button>
    <?php endif ?>
</div>
</body>


<script>
    $(function(){
        // 保存
        $("#save").click(function(event) {
            var id=$("#id").val();
            var result=$("#result").val();
            var type=$("#type").val();
            if(result!=''){
                $.post(getRootPath()+'/Home/My_feedback/writeResult/'+type+'/'+id, 
                    {result:result}, 
                    function(data) {
                    if(data.status){
                        $(document).dialog({
                            type : 'confirm',
                            style: 'ios',
                            content: data.msg,
                            buttons: [          
                                {
                                    name: '确定',
                                    callback: function() {
                                        history.back();
                                    }
                                }
                            ]
                        });
                        
                    }
                },"json");
            }else{
                $(document).dialog({
                    style: 'ios',
                    content: '请填写处理意见和结果'
                })
                            
            }
            
        });

        $("#end").click(function(event) {
            var id=$("#id").val();
            var result=$("#result").val();
            var type=$("#type").val();
            $.post(getRootPath()+'/Home/My_feedback/doEnd/'+type+'/'+id, 
                function(data) {
                if(data.status){
                    $(document).dialog({
                        type : 'confirm',
                        style: 'ios',
                        content: data.msg,
                        buttons: [          
                            {
                                name: '确定',
                                callback: function() {
                                    history.back();
                                }
                            }
                        ]
                    });
                    
                }
            },"json");
        });

        $("#relay").click(function(event) {
            // 弹窗遮罩
            $(".list").css('display','block');            
        });
    })
    // 搜索
    function change(){
        var id=$("#id").val();
        var type=$("#type").val();
        var param=$("#search").val();
        $.post($('input[name="url"]').val() + "Home/My_feedback/getAdminList/"+type+'/'+id, {param:param}, function(data) {
            if (data.status) {
                var t = JSON.parse(data.v);
                var html='';
                $.each(t, function(k, v) {
                     html+="<div onclick='getValue(this)' data-id='"+v['id']+"' data-value='"+v['username']+"【"+v['usercode']+"】'>"+v['username']+"【"+v['usercode']+"】"+"</div>";
                });
                $(".search-list").html(html);
            }
        }, "json"); 
    }
    // 点击搜索列表值，赋值到input上
    function getValue(obj){
        $("#search").val($(obj).attr('data-value'));
        $("#search").attr('data-id',$(obj).attr('data-id'));
        $("#forward").css('display', 'inline-block');
    }

    // 转发
    function doForward(){
        var id=$("#id").val();
        var type=$("#type").val();
        var belong=$("#search").attr('data-id');
        $.post($('input[name="url"]').val() + "Home/My_feedback/doForward/"+type+'/'+id, {belong:belong}, function(data) {
            if (data.status) {
                var t = JSON.parse(data.v);
                console.log(data.msg)
                $(document).dialog({
                    style: 'ios',
                    content: data.msg,
                    onClosed: function() {
                        location.reload();
                    }
                });      

            }
        }, "json"); 
        
    }
</script>
</html>
